<template>
  <div class="c-table">
    <div class="c-table__head">
      <div class="c-table__td select"><el-checkbox v-model="checkedAll" @change="checkedAllHandle" /></div>
      <div class="c-table__td goods-info">退货商品</div>
      <div class="c-table__td">买家信息</div>
      <div class="c-table__td">退货原因</div>
      <div class="c-table__td">审核方</div>
      <div class="c-table__td">退款金额</div>
      <div class="c-table__td">申请时间</div>
      <div class="c-table__td">操作</div>
    </div>
    <div class="c-table__body">
      <div class="c-table__row" v-for="(item, index) in currentData" :key="index">
        <div class="c-row__head">
          <div class="goods-type" :class="{'goods-type-2': item.goodsType === 1}">{{item.goodsType === 1 ? '批发' : '零售'}}</div>
          <div>申请单号：<span>{{item.resfundOrder}}</span></div>
          <div>关联单号：<span>{{item.orderNo}}</span></div>
          <div>[{{item.resfundType}}]</div>
        </div>
        <div class="c-table__tr" v-for="(tr, trIndex) in item.resfundGoods" :key="trIndex">
          <div class="c-table__td select">
            <el-checkbox v-model="tr.checked" @change="checkedHandle"/>
          </div>
          <div class="c-table__td v-align-c goods-info">
            <img :src="tr.imageUrl" alt="" class="width-65 height-65">
            <div class="line-2 mar-l-10">{{tr.goodsTitle}}</div>
          </div>
          <div class="c-table__td">
            <div>{{tr.customerName}}</div>
            <div>{{tr.customerPhone}}</div>
          </div>
          <div class="c-table__td">{{tr.resfundCause}}</div>
          <div class="c-table__td">{{tr.review}}</div>
          <div class="c-table__td">{{tr.resfundCoin}}</div>
          <div class="c-table__td">{{tr.applyTime}}</div>
          <div class="c-table__td">立即处理</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      checkedAll: false, // 全选
      headData: ['退货商品', '买家信息', '退货原因', '审核方', '退款金额', '申请时间', '操作'],
      currentData: [
        {
          resfundOrder: 123456789,
          orderNo: 13123123123,
          goodsType: 1,
          resfundType: '退款退货',
          applyTime: '2020-10-30 10:11:12',
          resfundGoods: [
            {
              imageUrl: 'https://veekrayimg.joinsun.vip/head-portrait.png',
              goodsTitle: '爱斯达克冷风机爱上咖啡机',
              customerName: 'xixiLi',
              customerPhone: '13023123123',
              resfundCause: '随意，想退',
              review: '总部',
              resfundCoin: '88.88',
              applyTime: '2020-10-30 10:12:11',
              checked: false
            }, {
              imageUrl: 'https://veekrayimg.joinsun.vip/head-portrait.png',
              goodsTitle: '爱斯达克冷风机爱上咖啡机',
              customerName: 'xixiLi',
              customerPhone: '13023123123',
              resfundCause: '随意，想退',
              review: '总部',
              resfundCoin: '88.88',
              applyTime: '2020-10-30 10:12:11',
              checked: false
            }, {
              imageUrl: 'https://veekrayimg.joinsun.vip/head-portrait.png',
              goodsTitle: '爱斯达克冷风机爱上咖啡机',
              customerName: 'xixiLi',
              customerPhone: '13023123123',
              resfundCause: '随意，想退',
              review: '总部',
              resfundCoin: '88.88',
              applyTime: '2020-10-30 10:12:11',
              checked: false
            }
          ]
        }, {
          resfundOrder: 123456789,
          orderNo: 13123123123,
          goodsType: 0,
          resfundType: '退款退货',
          applyTime: '2020-10-30 10:11:12',
          resfundGoods: [
            {
              imageUrl: 'https://veekrayimg.joinsun.vip/head-portrait.png',
              goodsTitle: '爱斯达克冷风机爱上咖啡机',
              customerName: 'xixiLi',
              customerPhone: '13023123123',
              resfundCause: '随意，想退',
              review: '总部',
              resfundCoin: '88.88',
              applyTime: '2020-10-30 10:12:11'
            }, {
              imageUrl: 'https://veekrayimg.joinsun.vip/head-portrait.png',
              goodsTitle: '爱斯达克冷风机爱上咖啡机',
              customerName: 'xixiLi',
              customerPhone: '13023123123',
              resfundCause: '随意，想退',
              review: '总部',
              resfundCoin: '88.88',
              applyTime: '2020-10-30 10:12:11'
            }, {
              imageUrl: 'https://veekrayimg.joinsun.vip/head-portrait.png',
              goodsTitle: '爱斯达克冷风机爱上咖啡机',
              customerName: 'xixiLi',
              customerPhone: '13023123123',
              resfundCause: '随意，想退',
              review: '总部',
              resfundCoin: '88.88',
              applyTime: '2020-10-30 10:12:11'
            }
          ]
        }, {
          resfundOrder: 123456789,
          orderNo: 13123123123,
          goodsType: 1,
          resfundType: '退款退货',
          applyTime: '2020-10-30 10:11:12',
          resfundGoods: [
            {
              imageUrl: 'https://veekrayimg.joinsun.vip/head-portrait.png',
              goodsTitle: '爱斯达克冷风机爱上咖啡机',
              customerName: 'xixiLi',
              customerPhone: '13023123123',
              resfundCause: '随意，想退',
              review: '总部',
              resfundCoin: '88.88',
              applyTime: '2020-10-30 10:12:11'
            }, {
              imageUrl: 'https://veekrayimg.joinsun.vip/head-portrait.png',
              goodsTitle: '爱斯达克冷风机爱上咖啡机',
              customerName: 'xixiLi',
              customerPhone: '13023123123',
              resfundCause: '随意，想退',
              review: '总部',
              resfundCoin: '88.88',
              applyTime: '2020-10-30 10:12:11'
            }, {
              imageUrl: 'https://veekrayimg.joinsun.vip/head-portrait.png',
              goodsTitle: '爱斯达克冷风机爱上咖啡机',
              customerName: 'xixiLi',
              customerPhone: '13023123123',
              resfundCause: '随意，想退',
              review: '总部',
              resfundCoin: '88.88',
              applyTime: '2020-10-30 10:12:11'
            }
          ]
        }
      ],
      checkList: []
    }
  },
  mounted() {
    this.currentData.forEach(item => {
      this.checkList.push(...item.resfundGoods)
    })
  },
  methods: {
    checkedAllHandle(val) {
      if (val) {
        this.checkList.forEach(item => {
          item.checked = true
        })
      } else {
        this.checkList.forEach(item => {
          item.checked = false
        })
      }
    },
    checkedHandle(val) {
      const isAll = this.checkList.findIndex(item => {
        return item.checked === false
      })
      if (isAll === -1) {
        this.checkedAll = true
      } else {
        this.checkedAll = false
      }
    }
  }
}
</script>
<style lang="less" scoped>
.c-table{
  .c-table__td{
    width: 200px;
    padding: 0 15px;
  }
  .c-table__head{
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
    background:#f7f8fa;
    color: #333333;
    .goods-info{
      width: 300px;
    }
    .select{
      width: 50px;
    }
    
  }
  .c-table__body{
    .c-table__row{
      .c-row__head{
        display: flex;
        align-items: center;
        justify-content: left;
        height: 50px;
        background-color: #f7f8fa;
        margin-top: 15px;
        border-top: 1px solid #edeff6;
        border-bottom: 1px solid #edeff6;
        position: relative;
        padding-left: 49px;
        .goods-type{
          position: absolute;
          left: 0;
          top: -1px;
          height: 25px;
          width: 39px;
          border-bottom-right-radius: 28px;
          background-color: #ffe100;
          line-height: 25px;
          font-size: 12px;
          box-sizing: border-box;
          padding-left: 4px;
        }
        .goods-type-2{
          background-color:#ff7024;
          color: white;
        }
      }
      .c-table__tr{
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid #edeff6;
        height: 95px;
        &:hover{
          background-color: #f7f8fa;
          cursor: pointer;
        }
        &:first-child{
          &:hover{
            background-color: unset;
          }
        }
        .goods-info{
          width: 300px;
        }
        .select{
          width: 50px;
        }
      }
    }
  }
}
</style>
